//
//  ScrollViewNextController.m
//  OneDay
//
//  Created by lanou3g on 15/11/2.
//  Copyright © 2015年 oneDay. All rights reserved.
//

#import "ScrollViewNextController.h"
#import "ScrollViewOneTableViewCell.h"
#import "ScrollViewTwoTableViewCell.h"

@interface ScrollViewNextController ()<UITableViewDataSource,UITableViewDelegate>


@property (nonatomic, strong) UITableView *tableView;

@property (nonatomic, strong) NSMutableArray *dataArray;
@end

@implementation ScrollViewNextController

- (void)viewDidLoad {
    [super viewDidLoad];
    NSString *url = [kScrollViewNext stringByAppendingString:[NSString stringWithFormat:@"?%ld", (long)self.scrollViewModel.ID]];
  
    self.scrollViewModel = [[ScrollViewNextModel alloc] init];
    [[OneDayManager shareManager] requestScrollViewNextDataWithUrl:url block:^(ScrollViewNextModel *model) {
        self.scrollViewModel = model;
        NSLog(@"-----%@", self.scrollViewModel);
    }];
    [self.tableView reloadData];
    [self addSubViews];
}

- (void)addSubViews
{
    self.tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    [self.view addSubview:self.tableView];
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifier = nil;
    if (indexPath.section == 0) {
        
        ScrollViewOneTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell ==  nil) {
            cell = [[ScrollViewOneTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            
        }
        ScrollViewNextModel *model = self.scrollViewModel;
        NSLog(@"%@", model);
        cell.model = model;
        return cell;
    } else {
        ScrollViewTwoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[ScrollViewTwoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        ScrollViewNextModel *model = self.scrollViewModel;
//        NSLog(@"%@",model);
        cell.model = model;
        return cell;
    }

}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section ==0) {
        return 470;
    } else
    {
        return 170;
    }
}







/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
